<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<meta content="telephone=no,email=no" name="format-detection">
<meta name="wap-font-scale" content="no"><title>选择礼券</title>
<!-- 公用样式css -->
<link href="css/base.css" rel="stylesheet" type="text/css" />
<!-- 内容css -->
<link href="css/card-package.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/idangerous.swiper.css">
<link href="css/interests-member.css" rel="stylesheet" type="text/css" />
<!-- ui框架引入css -->
<link href="css/bootstrap-switch.css" rel="stylesheet" type="text/css" />

</head>
<body style="background:#fff;">
<header class="header">
	<div class="header-left  wor-colour6" onclick="_back('${type}')">取消</div>
	<div class="header-center word5 "><a class="header-arrow">选择${title}</a></div>
	<div class="header-right wor-colour6" onclick="_selected('${type}')">确定</div>
</header>
<div class="main bot44">
	<div style="border-top: 1px solid #eee;padding: 15px 0 15px 0;text-align: center; background:#fbfbfb;"	>
    	<p class="wor-colour4">优惠券与免房券不可同时使用</p>
        <p>最多可使用1张${title}</p>
    </div>
	<ul class="defrayal" style="border-top: 0px;">
		<li class="word4"><span>不使用${title}</span>
			<span class="float-r">
				 <input name="status" type="checkbox" data-size="small" id="need">
		    </span>
		</li>
	</ul>
	<div id="fpdiv" style="display:none;"> 
		<c:if test="${not empty dataList}">
			<c:forEach var="info" items="${dataList}">
				<div class="coupon">
       				<input type="hidden" id="code" name="code" value="${info.Code}"/>
   					<ul class="coupon-pos" style="top:20%">
                     	<li style="padding:0px;margin:0px;">
                     		<div class="fit_box" style="margin-top:15%">
								<input type="radio" value="${info.Code}" id="checkbox${info.Code}" selTitle="${info.CouponName}" name="check">
								<label for="checkbox${info.Code}" ></label>
		 					</div>
		 					<div style="float:left;">
	                     		<p class="word6">${info.CouponName}</p>
								<p class="wor-colour5 marg2">${info.OverdueTime}</p>
								<p>有效期至： ${info.EndDate}</p>
								<a class="wor-colour6 ckgz " href="#" onclick="_seeRule(${info.RegularExplain});return false;">查看更多规则</a>
		 					</div>
						</li>
						<li class="word7 wor-colour9">￥${info.CouponMoney}</li>
					</ul>
    				<img class="coupon-img" src="images/icon36.png"/>
				</div>
			</c:forEach>
		</c:if>
		<c:if test="${empty dataList}"><img src="<%=basePath%>/images/icon38.png"></c:if>
	</div>
</div>
<script src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/jquery/swiper.js"></script>
<script type="text/javascript" src="js/bootstrap-switch.js"></script>
<script type="text/javascript" src="js/idangerous.swiper.min.js"></script>
<script type="text/javascript">
	 $(function() {// 初始化内容
        $('[name="status"]').bootstrapSwitch({
            onColor:"success",
            offColor:"default",
            size:"small",
            onSwitchChange:function(event,state){
                if(state==true){
                    $("#fpdiv").show();
                }else{
                    $("#fpdiv").hide();
                }
            }
        });
    });
	//查看更多规则
	function _seeRule(rule) {
	    alert(rule);
	}
	function _back(type) {
		if(type=="free"){
			$('#freeDiv', window.parent.document).hide();
		}else{
			$('#couponDiv', window.parent.document).hide();
		}
		$("#frame_div_back", window.parent.document).hide();
	}
	function _selected(type) {
		var selected = "";
		var title = "";
		if ($("#need").prop("checked")) {
			$("input[name='check']").each(function() {
				if ($(this).get(0).checked) {
					selected = $(this).val();
					title = $(this).attr("selTitle");
				}
			});
		}
		if(type=="free"){
			if(title == ""){
				title="不使用免房券";
			}else{
				$('#couponLi', window.parent.document).html("不使用优惠券");
				$('#couponCode', window.parent.document).val("");
			}
			$('#freeLi', window.parent.document).html(title);
			$('#freeRoomCode', window.parent.document).val(selected);
			$('#freeDiv', window.parent.document).hide();
		}else{
			if(title == ""){
				title="不使用优惠券";
			}else{
				$('#freeLi', window.parent.document).html("不使用免房券");
				$('#freeRoomCode', window.parent.document).val("");
			}
			$('#couponLi', window.parent.document).html(title);
			$('#couponCode', window.parent.document).val(selected);
			$('#couponDiv', window.parent.document).hide();
		}
		$("#frame_div_back", window.parent.document).hide();
		window.parent.getPrice();
	}
</script>
</body>
</html>
